<?php
class Embranchements extends CI_Controller{
	public function Nom($nom){
		require_once(APPPATH.'controllers/Menu.php');
		$menu=new Menu();
		
		$this->load->view('vHeader');
		$menu->index();
		$nomEmbranchement=str_replace("-", " ", $nom);
		
		$query=$this->doctrine->em->createQuery("SELECT e FROM Embranchement e WHERE e.nom='".$nomEmbranchement."'");
		$embranchements=$query->getResult();
		
		foreach ($embranchements AS $embranchement){
			
			$queryPlantes=$this->doctrine->em->createQuery("SELECT p FROM Plante p JOIN p.idembranchement e WHERE e.id=".$embranchement->getId());
			$plantes=$queryPlantes->getResult();
		}
		
		
		$this->load->view('vEmbranchement',array('embranchements'=>$embranchements,'nomEmbranchement'=>$nomEmbranchement,'plantes'=>$plantes));
		$this->load->view('vFooter');
	}
}